#ifndef __COMPONENT_FURNACE_H__
#define __COMPONENT_FURNACE_H__

#include "ComponentInventoryBase.h"

namespace PocketSurvival
{
    struct FurnaceRecipe;
    struct ComponentBlockEntity;

    struct ComponentFurnace : public ComponentInventoryBase
    {
        uint8_t furnaceRowSize;     // 行
        uint8_t furnaceColumnsSize; // 列
        bool updateSmeltingRecipe;
        bool isRun;

        float fireTimeRemaining;
        float heatLevel;
        float smeltingProgress;

        int32_t matchedIngredients[9];
        FurnaceRecipe *smeltingRecipe;
        ComponentBlockEntity *componentBlockEntity;

        virtual uint32_t getSlotCapacity(uint32_t slotIndex, int32_t cellValue) override;
        virtual void addSlotItems(uint32_t slotIndex, int32_t cellValue, uint32_t count) override;
        virtual uint32_t removeSlotItems(uint32_t slotIndex, uint32_t count) override;
        virtual void setSlotValue(uint32_t slotIndex, int32_t cellValue, uint32_t cellCount) override;

        inline uint32_t remainsSlotIndex();
        inline uint32_t resultSlotIndex();
        inline uint32_t fuelSlotIndex();

        FurnaceRecipe *findSmeltingRecipe(float heatLevel);


        virtual void update(float dt) override;
        virtual void save(nlohmann::json &jsonData) override;
        virtual void load(const nlohmann::json &jsonData) override;
        virtual const std::string &getName() const override;
        static const std::string &GetName();

    protected:
        
    };

    inline uint32_t ComponentFurnace::remainsSlotIndex()
    {
        return slotsCount() - 1;
    }
    inline uint32_t ComponentFurnace::resultSlotIndex()
    {
        return slotsCount() - 2;
    }
    inline uint32_t ComponentFurnace::fuelSlotIndex()
    {
        return slotsCount() - 3;
    }

} // namespace PocketSurvival

#endif
